package com.pr.makfilm.user.pages.room.create.design;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Pawel
 * Date: 01.10.13
 * Time: 00:26
 * To change this template use File | Settings | File Templates.
 */
public class DesignRow extends Panel
{
   private int rowId;

   private DesignCellRepeater cellRepeater;

   public DesignRow(String id, IModel<?> model, int rowId)
   {
      super(id, model);
      this.rowId = rowId;
   }

   @Override
   protected void onInitialize()
   {
      super.onInitialize();
      add(new Label("header", Model.of(rowId + 1)));
      add(cellRepeater = new DesignCellRepeater("cells", getDefaultModel(), rowId));
   }

   public List<DesignCell> getCells()
   {
      return cellRepeater.getCells();
   }

   @Override
   protected void onDetach()
   {
      super.onDetach();
      cellRepeater.detach();
   }
}
